<?php

namespace app\common\helper\sms;

use app\common\helper\sms\SmsAliHandler;

use app\common\helper\sms\SmsQiniuHandler;

use app\common\helper\sms\SmsQcloudHandler;

use app\common\logic\DataSettingLogic;



use think\Exception;



class SmsHelper{

    private $config;

    private $handler;

    public function __construct() {

        $DataSettingLogic = new DataSettingLogic();

        $this->config = $DataSettingLogic->getData('sms');

        switch ($this->config['type']){

            case 1:

                $this->handler = new SmsQiniuHandler($this->config['qiniu']);

                break;

            case 2:

                $this->handler = new SmsAliHandler($this->config['ali']);

                break;

            case 3:

                $this->handler = new SmsQcloudHandler($this->config['qcloud']);

                break;

        }

    }

    

    //发送平台验证码

    public function sendCode($mobile,$code){

        return $this->handler->sendSms($this->config['captcha_id'], [$mobile], ['code'=>$code]);

    }

    

   

   //预留通知短信接口 

    public function sendNotice($smsId,array $mobiles,$params){

        return $this->handler->sendSms($smsId, $mobiles, $params);

    }

    

}